#coding:utf-8
# import time
# from selenium import webdriver
# driver=webdriver.Firefox()
# driver.get('https://weibo.com/')
# name_field = driver.find_element_by_xpath('//input[@id="loginname"]')
# password_field=driver.find_element_by_name('password')
# submit_button=driver.find_element_by_class_name('W_btn_a btn_32px')
# name_field.send_keys('15967173981')
# password_field.send_keys('qiyinghua54')
# submit_button.click()
# driver.get_cookies()
# time.sleep(2)

import time
# from selenium import webdriver
# from selenium.webdriver.common.by import By
# from selenium.webdriver.support.ui import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
import requests
from bs4 import BeautifulSoup
import json


# driver = webdriver.Firefox(executable_path =r'E:\firefox\geckodriver-v0.18.0-win64\geckodriver.exe')
# driver.get('https://passport.weibo.cn/signin/login')
# WebDriverWait(driver, 20).until(
#     EC.presence_of_element_located((By.ID, 'loginName')))
# time.sleep(1)
#
# name_field = driver.find_element_by_id('loginName')
# name_field.clear()
# name_field.send_keys(str('17767072032'))
# password_field = driver.find_element_by_id('loginPassword')
# password_field.clear()
# password_field.send_keys('')
# submit_button = driver.find_element_by_id('loginAction')
# submit_button.click()
# ##https://m.weibo.cn/api/container/getIndex?containerid=100103type%253D60%2526q%253D%25E4%25B8%25AD%25E5%258D%25B0%25E6%25B4%259E%25E6%259C%2597&title=%25E7%2583%25AD%25E9%2597%25A8-%25E4%25B8%25AD%25E5%258D%25B0%25E6%25B4%259E%25E6%259C%2597&cardid=weibo_page&extparam=title%3D%E7%83%AD%E9%97%A8%26mid%3D%26q%3D%E4%B8%AD%E5%8D%B0%E6%B4%9E%E6%9C%97&luicode=10000011&lfid=100103type%3D1%26q%3D%E4%B8%AD%E5%8D%B0%E6%B4%9E%E6%9C%97&featurecode=20000320&type=all&page=1
# print(driver.get_cookies())
# cookie=driver.get_cookies()

# html=requests.get('https://m.weibo.cn/api/container/getIndex?containerid=100103type%253D60%2526q%253D%25E4%25B8%25AD%25E5%258D%25B0%25E6%25B4%259E%25E6%259C%2597&page=1')
# json=json.loads(html.content)
# rootlist = json.keys()
# print(rootlist)
# data=json['data']
# print(data)
# cards=data['cards'][0]
# print(cards)
# cardgroup=cards['card_group']
# print(cardgroup)
# for card in cardgroup:
#     print(card['mblog']['text'])

for x in range(1,20):
    s='https://m.weibo.cn/api/container/getIndex?containerid=100103type%253D60%2526q%253D%25E4%25B8%25AD%25E5%258D%25B0%25E6%25B4%259E%25E6%259C%2597&page='+str(x)
    print(s)
    html=requests.get(s)
    print(html)
    js = json.loads(html.content)
    rootlist = js.keys()
    data = js['data']
    cards = data['cards'][0]
    cardgroup = cards['card_group']
    for card in cardgroup:
        print(card['mblog']['text'])